package cn.bugstack.springframework.core.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @param
 * @author oyz
 * @version 1.0
 * @description: TODO 通过指定的文件路径来读取文件信息
 * @date 2022/3/20 15:00
 */
public class FileSystemResource implements Resource{

    private final File file;


    private final String path;


    public FileSystemResource(File file) {
        this.file = file;
        this.path = file.getPath();
    }


    public FileSystemResource(String path){
        this.file = new File(path);
        this.path = path;
    }


    public String getPath(){
        return  this.path;
    }

    @Override
    public InputStream getInputStream() throws IOException {

        return new FileInputStream(this.file);
    }
}
